package com.wangshupo.dewu.config;


import com.wangshupo.dewu.Interceptor.CheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 全局配置 管理拦截器
 */

@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Autowired
    private CheckInterceptor checkInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(checkInterceptor)
                .addPathPatterns("/api/**")

                .excludePathPatterns("/api/user/reg")
                .excludePathPatterns("/api/user/login")
                .excludePathPatterns("/api/user/toLogin")

                .excludePathPatterns("/css/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/error");

    }
}
